{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "def56743",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "import datetime as dt\n",
    "import tablib as tb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "15000e72",
   "metadata": {},
   "outputs": [],
   "source": [
    "dir = \"E:\\\\HQData\\\\future\\\\\"\n",
    "\n",
    "file_base = \"20250513_alltrade.csv\"\n",
    "file_main = \"20250513_allmain.csv\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e5179c15",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "file_main = \"20250513_allmain.csv\"\n",
    "\n",
    "df1 = pd.read_csv(f\"{dir}{file_base}\", index_col=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f05389cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "731"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df1.index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "978dd8b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>ts_code</th>\n",
       "      <th>symbol</th>\n",
       "      <th>exchange</th>\n",
       "      <th>name</th>\n",
       "      <th>fut_code</th>\n",
       "      <th>multiplier</th>\n",
       "      <th>trade_unit</th>\n",
       "      <th>per_unit</th>\n",
       "      <th>quote_unit</th>\n",
       "      <th>quote_unit_desc</th>\n",
       "      <th>d_mode_desc</th>\n",
       "      <th>list_date</th>\n",
       "      <th>delist_date</th>\n",
       "      <th>d_month</th>\n",
       "      <th>last_ddate</th>\n",
       "      <th>trade_time_desc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2356</th>\n",
       "      <td>2356</td>\n",
       "      <td>JD2604.DCE</td>\n",
       "      <td>JD2604</td>\n",
       "      <td>DCE</td>\n",
       "      <td>鸡蛋2604</td>\n",
       "      <td>JD</td>\n",
       "      <td>NaN</td>\n",
       "      <td>吨</td>\n",
       "      <td>5.0</td>\n",
       "      <td>人民币元/500千克</td>\n",
       "      <td>1人民币元/500千克</td>\n",
       "      <td>实物交割</td>\n",
       "      <td>20250428</td>\n",
       "      <td>20260427</td>\n",
       "      <td>202604</td>\n",
       "      <td>20260430.0</td>\n",
       "      <td>上午9:00-11:30，下午13:30-15:00，以及交易所规定的其他时间</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2473</th>\n",
       "      <td>2473</td>\n",
       "      <td>JD2603.DCE</td>\n",
       "      <td>JD2603</td>\n",
       "      <td>DCE</td>\n",
       "      <td>鸡蛋2603</td>\n",
       "      <td>JD</td>\n",
       "      <td>NaN</td>\n",
       "      <td>吨</td>\n",
       "      <td>5.0</td>\n",
       "      <td>人民币元/500千克</td>\n",
       "      <td>1人民币元/500千克</td>\n",
       "      <td>实物交割</td>\n",
       "      <td>20250327</td>\n",
       "      <td>20260326</td>\n",
       "      <td>202603</td>\n",
       "      <td>20260331.0</td>\n",
       "      <td>上午9:00-11:30，下午13:30-15:00，以及交易所规定的其他时间</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1145</th>\n",
       "      <td>1145</td>\n",
       "      <td>JD2602.DCE</td>\n",
       "      <td>JD2602</td>\n",
       "      <td>DCE</td>\n",
       "      <td>鸡蛋2602</td>\n",
       "      <td>JD</td>\n",
       "      <td>NaN</td>\n",
       "      <td>吨</td>\n",
       "      <td>5.0</td>\n",
       "      <td>人民币元/500千克</td>\n",
       "      <td>1人民币元/500千克</td>\n",
       "      <td>实物交割</td>\n",
       "      <td>20250226</td>\n",
       "      <td>20260224</td>\n",
       "      <td>202602</td>\n",
       "      <td>20260227.0</td>\n",
       "      <td>上午9:00-11:30，下午13:30-15:00，以及交易所规定的其他时间</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Unnamed: 0     ts_code  symbol exchange    name fut_code  multiplier  \\\n",
       "2356        2356  JD2604.DCE  JD2604      DCE  鸡蛋2604       JD         NaN   \n",
       "2473        2473  JD2603.DCE  JD2603      DCE  鸡蛋2603       JD         NaN   \n",
       "1145        1145  JD2602.DCE  JD2602      DCE  鸡蛋2602       JD         NaN   \n",
       "\n",
       "     trade_unit  per_unit  quote_unit quote_unit_desc d_mode_desc  list_date  \\\n",
       "2356          吨       5.0  人民币元/500千克     1人民币元/500千克        实物交割   20250428   \n",
       "2473          吨       5.0  人民币元/500千克     1人民币元/500千克        实物交割   20250327   \n",
       "1145          吨       5.0  人民币元/500千克     1人民币元/500千克        实物交割   20250226   \n",
       "\n",
       "      delist_date  d_month  last_ddate  \\\n",
       "2356     20260427   202604  20260430.0   \n",
       "2473     20260326   202603  20260331.0   \n",
       "1145     20260224   202602  20260227.0   \n",
       "\n",
       "                              trade_time_desc  \n",
       "2356  上午9:00-11:30，下午13:30-15:00，以及交易所规定的其他时间  \n",
       "2473  上午9:00-11:30，下午13:30-15:00，以及交易所规定的其他时间  \n",
       "1145  上午9:00-11:30，下午13:30-15:00，以及交易所规定的其他时间  "
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9b3f75d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "dfprogress = df1[['ts_code','list_date', 'delist_date']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "dbf85d16",
   "metadata": {},
   "outputs": [],
   "source": [
    "dfprogress.to_csv(dir + 'progress.csv', sep='|')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "df4f0150",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_9180\\1017650516.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  dfprogress['get_date'] = dt.datetime.today().strftime(\"%Y%m%d\")\n"
     ]
    }
   ],
   "source": [
    "dfprogress['get_date'] = dt.datetime.today().strftime(\"%Y%m%d\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "24869116",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20250712\n"
     ]
    }
   ],
   "source": [
    "print(dt.datetime.today().strftime(\"%Y%m%d\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "083af111",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>fget_date</th>\n",
       "      <th>ts_code</th>\n",
       "      <th>1get_date</th>\n",
       "      <th>list_date</th>\n",
       "      <th>delist_date</th>\n",
       "      <th>get_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2356</th>\n",
       "      <td>20250712</td>\n",
       "      <td>JD2604.DCE</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250428</td>\n",
       "      <td>20260427</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2473</th>\n",
       "      <td>20250712</td>\n",
       "      <td>JD2603.DCE</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250327</td>\n",
       "      <td>20260326</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1145</th>\n",
       "      <td>20250712</td>\n",
       "      <td>JD2602.DCE</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250226</td>\n",
       "      <td>20260224</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1539</th>\n",
       "      <td>20250712</td>\n",
       "      <td>JD2601.DCE</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250123</td>\n",
       "      <td>20260122</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2236</th>\n",
       "      <td>20250712</td>\n",
       "      <td>JD2512.DCE</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20241227</td>\n",
       "      <td>20251226</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1762</th>\n",
       "      <td>20250712</td>\n",
       "      <td>BR2509.SHF</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20240919</td>\n",
       "      <td>20250915</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>434</th>\n",
       "      <td>20250712</td>\n",
       "      <td>BR2508.SHF</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20240816</td>\n",
       "      <td>20250815</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2724</th>\n",
       "      <td>20250712</td>\n",
       "      <td>BR2507.SHF</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20240716</td>\n",
       "      <td>20250715</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>946</th>\n",
       "      <td>20250712</td>\n",
       "      <td>BR2506.SHF</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20240618</td>\n",
       "      <td>20250616</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1010</th>\n",
       "      <td>20250712</td>\n",
       "      <td>BR2505.SHF</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20240516</td>\n",
       "      <td>20250515</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>731 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     fget_date     ts_code 1get_date  list_date  delist_date  get_date\n",
       "2356  20250712  JD2604.DCE  20250712   20250428     20260427  20250712\n",
       "2473  20250712  JD2603.DCE  20250712   20250327     20260326  20250712\n",
       "1145  20250712  JD2602.DCE  20250712   20250226     20260224  20250712\n",
       "1539  20250712  JD2601.DCE  20250712   20250123     20260122  20250712\n",
       "2236  20250712  JD2512.DCE  20250712   20241227     20251226  20250712\n",
       "...        ...         ...       ...        ...          ...       ...\n",
       "1762  20250712  BR2509.SHF  20250712   20240919     20250915  20250712\n",
       "434   20250712  BR2508.SHF  20250712   20240816     20250815  20250712\n",
       "2724  20250712  BR2507.SHF  20250712   20240716     20250715  20250712\n",
       "946   20250712  BR2506.SHF  20250712   20240618     20250616  20250712\n",
       "1010  20250712  BR2505.SHF  20250712   20240516     20250515  20250712\n",
       "\n",
       "[731 rows x 6 columns]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfprogress"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "6152a2fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "dfprogress.insert(0,'fget_date', dt.datetime.today().strftime(\"%Y%m%d\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "db42b492",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>getdate</th>\n",
       "      <th>code</th>\n",
       "      <th>startdate</th>\n",
       "      <th>enddate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20250712</td>\n",
       "      <td>jd.2301</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    getdate     code startdate   enddate\n",
       "0  20250712  jd.2301  20250712  20250712"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfp = pd.DataFrame({\"getdate\": [dt.datetime.today().strftime(\"%Y%m%d\")],\n",
    "                   'code': ['jd.2301'],\n",
    "                   'startdate': [dt.datetime.today().strftime(\"%Y%m%d\")],\n",
    "                   'enddate': [dt.datetime.today().strftime(\"%Y%m%d\")]})\n",
    "\n",
    "\n",
    "dfp\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "a4d017dd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>getdate</th>\n",
       "      <th>code</th>\n",
       "      <th>startdate</th>\n",
       "      <th>enddate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20250712</td>\n",
       "      <td>jd.2301</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    getdate     code startdate   enddate\n",
       "0  20250712  jd.2301  20250712  20250712"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfp = pd.DataFrame({\"getdate\": [dt.datetime.today().strftime(\"%Y%m%d\")],\n",
    "                   'code': 'jd.2301',\n",
    "                   'startdate': dt.datetime.today().strftime(\"%Y%m%d\"),\n",
    "                   'enddate': dt.datetime.today().strftime(\"%Y%m%d\")})\n",
    "\n",
    "\n",
    "dfp\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "77eb7fd3",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_9180\\3312748852.py:6: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.\n",
      "  dfp.append([\"--\",\"--\",\"--\",\"--\"])\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>getdate</th>\n",
       "      <th>code</th>\n",
       "      <th>startdate</th>\n",
       "      <th>enddate</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20250712</td>\n",
       "      <td>jd.2301</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250712</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>--</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>--</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>--</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>--</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    getdate     code startdate   enddate    0\n",
       "0  20250712  jd.2301  20250712  20250712  NaN\n",
       "0       NaN      NaN       NaN       NaN   --\n",
       "1       NaN      NaN       NaN       NaN   --\n",
       "2       NaN      NaN       NaN       NaN   --\n",
       "3       NaN      NaN       NaN       NaN   --"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfp = pd.DataFrame()\n",
    "dfp.insert(0,\"getdate\",[ dt.datetime.today().strftime(\"%Y%m%d\")])\n",
    "dfp.insert(1,'code', 'jd.2301')\n",
    "dfp.insert(2,'startdate', dt.datetime.today().strftime(\"%Y%m%d\"))\n",
    "dfp.insert(3,'enddate', dt.datetime.today().strftime(\"%Y%m%d\"))\n",
    "dfp.append([\"--\",\"--\",\"--\",\"--\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "7acd8647",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_9180\\2272190090.py:1: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.\n",
      "  dfp.append({\"getdate\": '----------------',\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>getdate</th>\n",
       "      <th>code</th>\n",
       "      <th>startdate</th>\n",
       "      <th>enddate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20250712</td>\n",
       "      <td>jd.2301</td>\n",
       "      <td>20250712</td>\n",
       "      <td>20250712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>----------------</td>\n",
       "      <td>----------------</td>\n",
       "      <td>----------------</td>\n",
       "      <td>---------------</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            getdate              code         startdate          enddate\n",
       "0          20250712           jd.2301          20250712         20250712\n",
       "1  ----------------  ----------------  ----------------  ---------------"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfp.append({\"getdate\": '----------------',\n",
    "                   'code':  '----------------',\n",
    "                   'startdate':'----------------',\n",
    "                   'enddate':  '---------------'}, ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "30742394",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "        dfprogress = pd.DataFrame({\"getdate\": 'wee',\n",
    "                   'code':'wee',\n",
    "                   'startdate': 'wee',\n",
    "                   'enddate': ['wee']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "cccd1630",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>getdate</th>\n",
       "      <th>code</th>\n",
       "      <th>startdate</th>\n",
       "      <th>enddate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>wee</td>\n",
       "      <td>wee</td>\n",
       "      <td>wee</td>\n",
       "      <td>wee</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  getdate code startdate enddate\n",
       "0     wee  wee       wee     wee"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfprogress"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "57cb3c18",
   "metadata": {},
   "outputs": [],
   "source": [
    "dfprogress.to_csv(dir + 'progress2.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "56fba5ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "with open(dir + 'progress1.csv', 'a+',newline='') as f:\n",
    "    f.write(tb.Dataset().load(dfprogress.to_csv(index=False, header=None)).export('csv'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "d8362397",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'pro' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[80], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m df1 \u001b[38;5;241m=\u001b[39m \u001b[43mpro\u001b[49m\u001b[38;5;241m.\u001b[39mfut_daily(trade_date\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m20250709\u001b[39m\u001b[38;5;124m'\u001b[39m, exchange\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDCE\u001b[39m\u001b[38;5;124m'\u001b[39m, fields\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mts_code,trade_date,pre_close,pre_settle,open,high,low,close,settle,vol\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'pro' is not defined"
     ]
    }
   ],
   "source": [
    "df = pro.fut_daily(trade_date='20250709', exchange='DCE', fields='ts_code,trade_date,pre_close,pre_settle,open,high,low,close,settle,vol')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "baa1315f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>getdate</th>\n",
       "      <th>code</th>\n",
       "      <th>startdate</th>\n",
       "      <th>enddate</th>\n",
       "      <th>gettime</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20250712</td>\n",
       "      <td>code</td>\n",
       "      <td>start_date</td>\n",
       "      <td>end_date</td>\n",
       "      <td>224343</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    getdate  code   startdate   enddate gettime\n",
       "0  20250712  code  start_date  end_date  224343"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({\"getdate\": [dt.datetime.now().strftime(\"%Y%m%d\")],\n",
    "                   'code': ['code'],\n",
    "                   'startdate': ['start_date'],\n",
    "                   'enddate': ['end_date'],\n",
    "                   'gettime':[dt.datetime.now().strftime(\"%H%M%S\")]})\n",
    "\n",
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "72e37a16",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
